﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WSDLFlattener
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private MainWindowController _controller;
        private ObservableCollection<string> _namespacesToRemove;

        public MainWindow()
        {
            InitializeComponent();

            _controller = new MainWindowController();
            _namespacesToRemove = new ObservableCollection<string>();
            _namespacesToRemove.Add("http://schemas.microsoft.com/2003/10/Serialization/");
            this.lstNsToRemove.ItemsSource = _namespacesToRemove;

        }

        private void btnFlatten_Click(object sender, RoutedEventArgs e)
        {
            string wsdlUri = this.txtWSDL.Text;
            _controller.FlattenWSDL(wsdlUri, _namespacesToRemove.ToList<string>());
        }

        private void btnAddNs_Click(object sender, RoutedEventArgs e)
        {
            PromptWindow prompt = new PromptWindow() { Title = "Enter Namespace", Message = "Please enter namespace to remove" };
            prompt.ShowDialog();
            
            _namespacesToRemove.Add(prompt.Value);
        }

        private void btnDelNS_Click(object sender, RoutedEventArgs e)
        {
            string nsToDelete = this.lstNsToRemove.SelectedItem as string;
            if (!string.IsNullOrEmpty(nsToDelete))
                _namespacesToRemove.Remove(nsToDelete);
        }
    }
}
